//
//  HLRTCVideoView.m
//  YueYue
//
//  Created by hulu001 on 2023/6/20.
//

#import "HLRTCVideoView.h"

@implementation HLRTCVideoView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = UIColorBlack;
        
        self.tipLabel = [[UILabel alloc] qmui_initWithFont:UIFontMake(14) textColor:UIColorWhite];
        _tipLabel.numberOfLines = 0;
        _tipLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:_tipLabel];
        [_tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(6);
            make.right.mas_equalTo(-6);
            make.centerY.mas_equalTo(0);
        }];
        [self addTapGesture];
        self.enableGesture = YES;
    }
    return self;
}


- (void)addTapGesture
{
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapEvent:)];
    [self addGestureRecognizer:tap];
}

- (void)tapEvent:(UITapGestureRecognizer *)tap
{
    if (!self.enableGesture) {
        return;
    }
    if (self.delegate && [self.delegate respondsToSelector:@selector(onTapVideoView:)]) {
        [self.delegate onTapVideoView:self];
    }
}

- (void)becomeBig
{
    self.isSmall = NO;
    self.layer.cornerRadius = 0;
    [self mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT));
        make.edges.mas_equalTo(0);
    }];
    [self setNeedsLayout];
}

- (void)becomeSmall
{
    self.isSmall = YES;
    [self mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(88, 120));
        make.right.mas_equalTo(-12);
        make.top.mas_equalTo(NavigationContentTopConstant + 12);
    }];
    self.layer.cornerRadius = 8;
    self.layer.masksToBounds = YES;
    [self setNeedsLayout];
}


@end
